<template>
  <div class="tab-box">
    <div class="pc">
      <div class="navbar-box">
        <div class="navbar-title">
          {{ componentData[`title${capitalizeLang}`] }}
        </div>
        <div class="navbar-subtitle">
          <span>{{ $t('common.released') }}: {{ createTime }}</span>
          <span>{{ $t('common.source') }}: {{ componentData[`source${capitalizeLang}`] }}</span>
        </div>
        <div v-for="(item, index) in componentData.list" :key="index" class="navbar-in">
          <p
            v-if="item.type === 'text'"
            :class="{
              indent: item.indent === '1',
              'align-ct': item.align === '2',
              'align-fr': item.align === '3',
            }"
            class="navbar-content"
          >
            {{ item.content }}
          </p>
          <template v-if="item.type === 'image'">
            <div v-for="(c, cindex) in item.content" :key="cindex" class="navbar-image">
              <img :src="c.response" alt="" />
              <a v-if="item.url" :href="item.url" target="_blank">
                {{
                  capitalizeLang === 'Zh'
                    ? '点击图片(查看原文)'
                    : 'Click on the image (view original article)'
                }}
              </a>
            </div>
          </template>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  props: {
    componentData: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {}
  },
  computed: {
    ...mapGetters(['capitalizeLang']),
    createTime() {
      return this.$route.query.createTime
    },
  },
}
</script>

<style lang="less" scoped>
@import '~assets/var';

.tab-box {
  background: #fff;
  .pd(0, 0, 60, 0);

  .pc {
    .width(1200);
    .pd(0, 0, 0, 0);

    background: #f6f7f9;
    color: #fff;
    margin: 0 auto;

    .navbar-box {
      .mg(0, 100, 0, 100);

      display: flex;
      flex-direction: column;
    }

    .navbar-in {
      .mg(0, 0, 0, 0);
      .lineH(24);
      .ft(16);
    }

    .navbar-title {
      .ft(24);
      .pd(60, 0, 16, 0);
      .mg(0, 0, 16, 0);
      .lineH(30);

      border-bottom: 1px solid #ddd;
      font-weight: bold;
      color: #333;
      text-align: center;
    }

    .navbar-subtitle {
      .ft(16);
      .mg(0, 0, 20, 0);

      color: #888;
      text-align: center;

      span {
        .mg(0, 70, 0, 70);
      }
    }

    .navbar-image {
      img {
        width: 100%;
        .mg(0, 0, 20, 0);
      }

      a {
        color: #999;
        display: block;
        text-align: center;
        cursor: pointer;
        .mg(-20, 0, 20, 0);

        &:hover {
          color: #005cb9;
        }
      }
    }

    .navbar-content {
      .mg(0, 0, 20, 0);
      .ft(16);
      .lineH(24);

      color: #333;

      &.indent {
        text-indent: 2em;
      }

      &.align-ct {
        text-align: center;
      }

      &.align-fr {
        text-align: right;
      }
    }
  }
}
</style>
